package keeto.com.vn.bms.network.task;

import java.io.IOException;

import keeto.com.vn.bms.config.IBMSCore;
import keeto.com.vn.bms.network.IBMSProtocol;
import keeto.com.vn.bms.network.response.getAndroidNotificationsReponse;
import keeto.com.vn.bms.utils.BMSListener;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

public class TaskGetAndroidNotifications extends AbstractTask{
	String authenKey;
	public TaskGetAndroidNotifications(BMSListener listener, IBMSCore core, String authenKey) {
		super(listener, core);
		this.authenKey = authenKey;
	}

	@Override
	public void run() throws ClientProtocolException, JSONException,IOException {
		getAndroidNotificationsReponse reponse = protocol.getAndroidNotifications(authenKey);
		for(BMSListener mListener:listener){
			mListener.finishgetAndroidNotifications(reponse.getCountPage(), reponse.getResultCode(), reponse.getResultMsg(), reponse.getListAndroidNotificationsModels());
		} 
	}

	@Override
	public void timeoutCallback() {
		for(BMSListener mListener:listener){
			mListener.finishgetAndroidNotifications(0, IBMSProtocol.STATUS_CODE_GENERIC_FAIL_CONECTTION, "", null);
		} 
	}
	
}
